need help with this code   #include <iostream> #include <cstring> #include <iomanip> #include <vector>   using namespace std;   int main() {  //define a list of vars & input double days; double departure_time; double...

profilekaygui

need help with this code

 

#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
 
using namespace std;
 
int main()
{
 //define a list of vars & input
double days;
double departure_time;
double arrival_time ;
double airfarefee;
double car_rental;
double milesCost = 0.27;
int privateVehicle, Miles;
double perDay = 6, cost;
double taxi_fee_function;
double total_for_taxi;
double Taxi_company_pays_fee=10; // this is how much company will pay for the taxi per day
double taxi_company_total_pay=Taxi_company_pays_fee*days; //this is how much company will pay for the TOTAL taxi
double taxi_cost; // total taxi cost before discounts
double totalReimbursed = 0;
double employeeExpenses = 0;
double totalExpenses = 0;
   
 cout << "How much was the air fare?";
 cin >> airfarefee;
 cout << "Did you rent a car?";
 cin >> car_rental;
 
 cout << "How many days were spent on the trip?";
 cin  >> days;
 cout << "How long was the departure of the trip?";
 cin  >> departure_time;
 cout << "How long was the arrival back home?";
 cin  >> arrival_time;
 
//This function calculates the cost for how many miles the user has driven
//void MilesDriven()
{
double milesCost = 0.27;
int privateVehicle, Miles;
 
cout << "How many miles did you drive on the trip?" << endl;
cin >> Miles;
cout << "You drove " << Miles << " in total." << endl;
cout << "The total cost of drving your personal vehicle is $" << (Miles * milesCost);
}
 
//This function will calculate whether the employee will be covered for parking/how how much he will need to pay
//void parkingFees()
{
double perDay = 6, cost;
 
cout << "The company allows $6 per day for parking." << endl;
cout << "How much was the parking cost for for today?" << endl;
cin >> cost; 
 
if(cost < perDay)
{
cout << "You spent " << cost << " on parking today." << endl; 
cout << "You will be fully reimbursed." << endl;
}
else
{
cout << "You have spent " << cost << " on parking today and will need to pay " << (cost - perDay) << " out of pocket." << endl;
    }
 
  double taxi_fee_function(double total_for_taxi)
  {//taxi_fee_function
 
  char taxiused_y_or_n;
  double Taxi_company_pays_fee=10; // this is how much company will pay for the taxi per day
  double taxi_company_total_pay=Taxi_company_pays_fee*days; //this is how much company will pay for the TOTAL taxi
  double taxi_cost; // total taxi cost before discounts
  cout <<"Was the taxi used at all during this trip? (Y)es or (N)o" << endl;
  cin >>taxiused_y_or_n; // asking weather taxi was
  used or not
 
 
if (taxiused_y_or_n =='Y') // IF STATEMENT asking weather taxi was used or not
 
 
{
cout <<"How much did it cost you for your taxi?"<<'\n';
cin >>taxi_cost;
double total_for_taxi;
 
total_for_taxi=taxi_cost-taxi_company_total_pay; //
total for taxi after discounts
 
if (total_for_taxi<=0) // if number is in negative then make it $0
 
{
total_for_taxi=0;
}
 
}
 
 
else
{
total_for_taxi=0;
}
 
return total_for_taxi;
}
}
 
cout <<"How much was the registeration fee?"<<endl; //Determines how much is registration fee
cin>>reg_fee;
cout <<"How much was the conference fee?"<<endl; //Determines how much is conference fee
cin>>conf_fee;
total_conf_n_reg_fees;
total_conf_n_reg_fees=reg_fee+conf_fee;
return total_conf_n_reg_fees; //Finds the TOTAL of registration and conference fee
 
const int NON_NEG = 0;
 
double days,
   departureTime,
   arrivalTime,
   totalReimbursed = 0,
   employeeExpenses = 0,
   totalExpenses = 0;
 
 
void meals(); //Calculates expenses on meals
void hotelExpenses(); //Calculates expenses on Hotel Fees
void inputVal(double &); //Tests for valid numbers (doubles)
 
int main()
{
cout << "Please enter the amount of days spent on trip: ";
cin >> days;
inputVal(days);
meals();
hotelExpenses();
 
system("PAUSE");
return 0;
 
}
 
void inputVal(double &num1)
{
while(num1 < NON_NEG)
{
cout << "The number you have entered is invalid." << endl;
cout << "Please enter a number greater than " << NON_NEG << ":";
cin >> num1;
}
}
 
void meals()
{
//Input
const int FIRST_BREAKFAST_TIME = 7,
  FIRST_LUNCH_TIME = 12,
  FIRST_DINNER_TIME = 18,
  LAST_BREAKFAST_TIME = 8,
  LAST_LUNCH_TIME = 13,
  LAST_DINNER_TIME = 19;
const double MAX_BREAKFAST = 9,
 MAX_LUNCH = 12,
 MAX_DINNER =16;
 
int numMeals = 0;
double tripMeal,
   firstMeal = 0,
   lastMeal = 0,
   excessMeal = 0,
   reimbursedMeal = 0,
   totalMeal = 0;
 
cout << "Please note time is kept in the 24-hour system." << endl;
cout << "Please enter your departure time: ";
cin >> departure_time;
inputVal(departure_time);
if(departure_time < FIRST_BREAKFAST_TIME)
{
cout << "You made it in time for Breakfast!" << endl;
cout << "Please enter how much you spent: $";
cin >> firstMeal;
inputVal(firstMeal);
if(firstMeal < MAX_BREAKFAST)
reimbursedMeal += firstMeal;
else
reimbursedMeal += MAX_BREAKFAST;
}
else if(departure_time < FIRST_LUNCH_TIME)
{
cout << "You made it in time for Lunch!" << endl;
cout << "Please enter how much you spent: $";
cin >> firstMeal;
inputVal(firstMeal);
if(firstMeal < MAX_LUNCH)
reimbursedMeal += firstMeal;
else
reimbursedMeal += MAX_LUNCH;
}
else if(departure_time < FIRST_DINNER_TIME)
{
cout << "You made it in time for Dinner!" << endl;
cout << "Please enter how much you spent: $";
cin >> firstMeal;
inputVal(firstMeal);
if(firstMeal < MAX_DINNER)
reimbursedMeal += firstMeal;
else
reimbursedMeal += MAX_DINNER;
}
else
{
cout << "You did not make it in time to eat on the first day. :/" << endl;
}
 
cout << "Please enter your arrival time: ";
cin >> arrival_time;
inputVal(arrival_time);
if(arrival_time < LAST_BREAKFAST_TIME)
{
cout << "You made it in time for Breakfast!" << endl;
cout << "Please enter how much you spent: $";
cin >> lastMeal;
inputVal(lastMeal);
if(lastMeal < MAX_BREAKFAST)
reimbursedMeal += lastMeal;
else
reimbursedMeal += MAX_BREAKFAST;
}
else if(arrival_time < LAST_LUNCH_TIME)
{
cout << "You made it in time for Lunch!" << endl;
cout << "Please enter how much you spent: $";
cin >> lastMeal;
inputVal(lastMeal);
if(lastMeal < MAX_LUNCH)
reimbursedMeal += lastMeal;
else
reimbursedMeal += MAX_LUNCH;
}
else if(arrival_time < LAST_DINNER_TIME)
{
cout << "You made it in time for Dinner!" << endl;
cout << "Please enter how much you spent: $";
cin >> lastMeal;
inputVal(lastMeal);
if(lastMeal < MAX_DINNER)
reimbursedMeal += lastMeal;
else
reimbursedMeal += MAX_DINNER;
}
else
{
cout << "You did not make it in time to eat on the last day. :/" << endl;
}
 
cout << "All the other meals eaten during the trip are fully reimbursed." << endl;
cout << "Please enter the amount spent on food: $";
cin >> tripMeal;
inputVal(tripMeal);
 
//Processing
reimbursedMeal += tripMeal;
totalMeal = tripMeal + firstMeal + lastMeal;
 
if(totalMeal < reimbursedMeal)
excessMeal = 0;
else
excessMeal = totalMeal - reimbursedMeal;
 
employeeExpenses += excessMeal;
totalExpenses += totalMeal;
 
//Output
cout << endl;
cout << setprecision(2) << fixed;
cout << "Meal Info" << right << setw(22) << "Amount" << left << endl;
cout << "===========" << right << setw(22) << "==========" << left << endl;
cout << "Total" << right << setw(28) << totalMeal << left << endl;
cout << "Reimbursed" << right << setw(23) << reimbursedMeal << left << endl;
cout << "Excess" << right << setw(27) << excessMeal << left << endl << endl;
}
 
void hotelExpenses()
{
//Input
const double HOTEL_MAX = 90;
double totalHotel = 0,
   reimbursedHotel = 0,
   excessHotel = 0;
vector<double> nightlyHotel(days, 0);
 
cout << "Please enter the nightly hotel expenses for" << endl;
cout << "the " << int(days) << " days of the trip:" << endl;
for(int counter = 0; counter < days; counter++)
{
cout << "Night " << (counter + 1) << ": $";
cin >> nightlyHotel[counter];
inputVal(nightlyHotel[counter]);
}
 
//Processing
for(int counter = 0; counter < days; counter++)
{
if(nightlyHotel[counter] < HOTEL_MAX)
reimbursedHotel += nightlyHotel[counter];
else
reimbursedHotel += HOTEL_MAX;
 
totalHotel += nightlyHotel[counter];
}
if(totalHotel < reimbursedHotel)
excessHotel = 0;
else
excessHotel = totalHotel - reimbursedHotel;
 
//Output
cout << endl;
cout << setprecision(2) << fixed;
cout << "Hotel Info" << right << setw(22) << "Amount" << left << endl;
cout << "============" << right << setw(22) << "==========" << left << endl;
cout << "Total" << right << setw(29) << totalHotel << left << endl;
cout << "Reimbursed" << right << setw(24) << reimbursedHotel << left << endl;
cout << "Excess" << right << setw(28) << excessHotel << left << endl << endl;
}
 
 
 system("pause");
 return 0;   
 

 

}
    • 10 years ago
    • 999999.99
    Answer(0)
    Bids(0)